package com.sanyou.config;

import com.sanyou.filter.UserFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Arrays;

/**
 * 过滤器Bean配置类
 * 所有的过滤器相关的Bean配置都应该放在这个类里
 * User: asus
 * Date: 2021/6/8
 * Time: 16:55
 * Version:V1.0
 */
@Configuration
public class FilterConfig{

    /**
     * 配置用户拦截相关的过滤器
     * @return
     */
    @Bean
    FilterRegistrationBean filterRegistrationBean(){
        FilterRegistrationBean bean = new FilterRegistrationBean();
        //配置用户拦截相关的过滤器
        bean.setFilter(new UserFilter());
        //设置过滤器优先级
        bean.setOrder(1);
        //配置该过滤器拦截的路径
        bean.setUrlPatterns(Arrays.asList("/user/*","/factory/*","/userGroup/*","/role/*","/resource/*","/userLog/*",
                "/equipment/*","/project/*","/order/*","/product/*","/menu/*"));
        return bean;
    }

}
